$(function() {
	$("#jqGrid").jqGrid({
		url: baseURL + 'gaokaobaobei/agency/getMyBaobeiList',
		datatype: "json",
		colModel: [{
				label: '代理人姓名',
				name: 'name',
				index: 'name',
				width: 60
			},
			{
				label: '单位',
				name: 'unit',
				index: 'unit',
				width: 100
			},
			{
				label: '联系电话',
				name: 'phone',
				index: 'phone',
				width: 80
			},
			{
				label: '夏考',
				name: 'xiakaoCount',
				index: 'xiakaoCount',
				width: 40,
				formatter: function(data, a, rows) {
					return `<span style="cursor:pointer;" onclick="selectXiakao('${rows.name}')">${data}</span>`
				}
			},
			{
				label: '单招',
				name: 'danzhaoCount',
				index: 'danzhaoCount',
				width: 40,
				formatter: function(data, a, rows) {
					return `<span style="cursor:pointer;" onclick="selectDanzhao('${rows.name}')">${data}</span>`
				}
			},
			{
				label: '专升本',
				name: 'shengbenCount',
				index: 'shengbenCount',
				width: 40,
				formatter: function(data, a, rows) {
					return `<span style="cursor:pointer;" onclick="selectShengben('${rows.name}')">${data}</span>`
				}
			},
			{
				label: '考研',
				name: 'kaoyanCount',
				index: 'kaoyanCount',
				width: 40,
				formatter: function(data, a, rows) {
					return `<span style="cursor:pointer;" onclick="selectKaoyan('${rows.name}')">${data}</span>`
				}
			},
			{
				label: '合作时间',
				name: 'cooperationtime',
				index: 'cooperationtime',
				width: 80
			},
		],
		viewrecords: true,
		height: 385,
		rowNum: 10,
		rowList: [10, 30, 50],
		rownumbers: true,
		rownumWidth: 25,
		autowidth: true,
		multiselect: true,
		pager: "#jqGridPager",
		jsonReader: {
			root: "page.list",
			page: "page.currPage",
			total: "page.totalPage",
			records: "page.totalCount"
		},
		prmNames: {
			page: "page",
			rows: "limit",
			order: "order"
		},
		gridComplete: function() {
			//隐藏grid底部滚动条
			$("#jqGrid").closest(".ui-jqgrid-bdiv").css({
				"overflow-x": "hidden"
			});
		}
	});
	$("#jqGridXiakao").jqGrid({
		url: baseURL + 'gaokaobaobei/zhaosheng/listXiakao',
		datatype: "json",
		colModel: [{
				label: '姓名',
				name: 'name',
				index: 'name',
				width: 100
			},
			{
				label: '考号',
				name: 'candidateNumber',
				index: 'candidate_number',
				width: 210
			},
			{
				label: '文理属性',
				name: 'wlProperty',
				index: 'wl_property',
				width: 100
			},
			{
				label: '分数',
				name: 'score',
				index: 'score',
				width: 100
			},
			{
				label: '高中',
				name: 'highSchool',
				index: 'high_school',
				width: 110
			},
			{
				label: '联系电话',
				name: 'phone',
				index: 'phone',
				width: 150
			},
			{
				label: '报备时间',
				name: 'creationDate',
				index: 'creation_date',
				width: 210
			},
			{
				label: '备注',
				name: 'candidateNumber',
				index: 'candidate_number',
				width: 210,
				formatter: function(data, a, rows) {
					if(rows.type == '等待录取结果') {
						return `备注:`;
					} else if(rows.type == '审核未通过') {
						return `<font color="#228b22">备注:${rows.school}</font>&nbsp;&nbsp;<font color="red">原因:${rows.major}</font> `;
					} else {
						return `<font color="#228b22">备注:${rows.school}</font> `;
					}
					if(rows.type == '等待录取结果') {
						return `${data}<br>备注:<input id="xk${data}" />`;
					} else if(rows.type == '审核未通过') {
						return `${data}<br><font color="#228b22">备注:${rows.school}</font>&nbsp;&nbsp;<font color="red">原因:${rows.major}</font> `;
					} else {
						return `${data}<br><font color="#228b22">备注:${rows.school}</font> `;
						if(rows.type == '等待录取结果') {
							return `备注:<input id="xk${data}" />`;
						} else if(rows.type == '审核未通过') {
							return `<font color="#228b22">备注:${rows.school}</font>&nbsp;&nbsp;<font color="red">原因:${rows.major}</font> `;
						} else {
							return `<font color="#228b22">备注:${rows.school}</font> `;
						}
					}

				}
			},
			{
				label: '状态',
				name: 'cz',
				index: 'cz',
				width: 100,
				formatter: function(data, a, rows) {
					if(rows.type == '审核通过') {
						return `<font color="#228b22">审核通过</font>`
					}
				}
			},
		],
		viewrecords: true,
		height: 385,
		rowNum: 10,
		rowList: [10, 30, 50],
		rownumbers: true,
		rownumWidth: 25,
//		autowidth: true,
		multiselect: true,
		pager: "#jqGridPagerXiakao",
		jsonReader: {
			root: "page.list",
			page: "page.currPage",
			total: "page.totalPage",
			records: "page.totalCount"
		},
		prmNames: {
			page: "page",
			rows: "limit",
			order: "order"
		},
		gridComplete: function() {
			//隐藏grid底部滚动条
			$("#jqGridXiakao").closest(".ui-jqgrid-bdiv").css({
				"overflow-x": "hidden"
			});
		}
	});
	$("#jqGridDanzhao").jqGrid({
		url: baseURL + 'gaokaobaobei/zhaosheng/listDanzhao',
		datatype: "json",
		colModel: [{
				label: '姓名',
				name: 'name',
				index: 'name',
				width: 80
			},
			{
				label: '考号',
				name: 'candidateNumber',
				index: 'candidate_number',
				width: 120
			},
			{
				label: '分数',
				name: 'score',
				index: 'score',
				width: 80
			},
			{
				label: '大学',
				name: 'highSchool',
				index: 'high_school',
				width: 110
			},
			{
				label: '联系电话',
				name: 'phone',
				index: 'phone',
				width: 110
			},
			{
				label: '报备时间',
				name: 'creationDate',
				index: 'creation_date',
				width: 150
			},
			{
				label: '备注',
				name: 'candidateNumber',
				index: 'candidate_number',
				width: 120,
				formatter: function(data, a, rows) {
					if(rows.type == '等待录取结果') {
						return `备注:`;
					} else if(rows.type == '审核未通过') {
						return `<font color="#228b22">备注:${rows.school}</font>&nbsp;&nbsp;<font color="red">原因:${rows.major}</font> `;
					} else {
						return `<font color="#228b22">备注:${rows.school}</font> `;
					}
					if(rows.type == '等待录取结果') {
						return `${data}<br>备注:<input id="xk${data}" />`;
					} else if(rows.type == '审核未通过') {
						return `${data}<br><font color="#228b22">备注:${rows.school}</font>&nbsp;&nbsp;<font color="red">原因:${rows.major}</font> `;
					} else {
						return `${data}<br><font color="#228b22">备注:${rows.school}</font> `;
						if(rows.type == '等待录取结果') {
							return `备注:<input id="xk${data}" />`;
						} else if(rows.type == '审核未通过') {
							return `<font color="#228b22">备注:${rows.school}</font>&nbsp;&nbsp;<font color="red">原因:${rows.major}</font> `;
						} else {
							return `<font color="#228b22">备注:${rows.school}</font> `;
						}
					}

				}
			},
			{
				label: '状态',
				name: 'cz',
				index: 'cz',
				width: 100,
				formatter: function(data, a, rows) {
					if(rows.type == '审核通过') {
						return `<font color="#228b22">审核通过</font>`
					}
				}
			},
		],
		viewrecords: true,
		height: 385,
		rowNum: 10,
		rowList: [10, 30, 50],
		rownumbers: true,
		rownumWidth: 25,
		autowidth: true,
		multiselect: true,
		pager: "#jqGridPagerDanzhao",
		jsonReader: {
			root: "page.list",
			page: "page.currPage",
			total: "page.totalPage",
			records: "page.totalCount"
		},
		prmNames: {
			page: "page",
			rows: "limit",
			order: "order"
		},
		gridComplete: function() {
			//隐藏grid底部滚动条
			$("#jqGridDanzhao").closest(".ui-jqgrid-bdiv").css({
				"overflow-x": "hidden"
			});
		}
	});
	$("#jqGridShengben").jqGrid({
		url: baseURL + 'gaokaobaobei/zhaosheng/listShengben',
		datatype: "json",
		colModel: [{
				label: '姓名',
				name: 'name',
				index: 'name',
				width: 80
			},
			{
				label: '考号',
				name: 'candidateNumber',
				index: 'candidate_number',
				width: 120
			},
			{
				label: '分数',
				name: 'score',
				index: 'score',
				width: 80
			},
			{
				label: '大学',
				name: 'highSchool',
				index: 'high_school',
				width: 110
			},
			{
				label: '联系电话',
				name: 'phone',
				index: 'phone',
				width: 110
			},
			{
				label: '报备时间',
				name: 'creationDate',
				index: 'creation_date',
				width: 150
			},
			{
				label: '备注',
				name: 'candidateNumber',
				index: 'candidate_number',
				width: 120,
				formatter: function(data, a, rows) {
					if(rows.type == '等待录取结果') {
						return `备注:`;
					} else if(rows.type == '审核未通过') {
						return `<font color="#228b22">备注:${rows.school}</font>&nbsp;&nbsp;<font color="red">原因:${rows.major}</font> `;
					} else {
						return `<font color="#228b22">备注:${rows.school}</font> `;
					}
					if(rows.type == '等待录取结果') {
						return `${data}<br>备注:<input id="xk${data}" />`;
					} else if(rows.type == '审核未通过') {
						return `${data}<br><font color="#228b22">备注:${rows.school}</font>&nbsp;&nbsp;<font color="red">原因:${rows.major}</font> `;
					} else {
						return `${data}<br><font color="#228b22">备注:${rows.school}</font> `;
						if(rows.type == '等待录取结果') {
							return `备注:<input id="xk${data}" />`;
						} else if(rows.type == '审核未通过') {
							return `<font color="#228b22">备注:${rows.school}</font>&nbsp;&nbsp;<font color="red">原因:${rows.major}</font> `;
						} else {
							return `<font color="#228b22">备注:${rows.school}</font> `;
						}
					}

				}
			},
			{
				label: '状态',
				name: 'cz',
				index: 'cz',
				width: 100,
				formatter: function(data, a, rows) {
					if(rows.type == '审核通过') {
						return `<font color="#228b22">审核通过</font>`
					}
				}
			},
		],
		viewrecords: true,
		height: 385,
		rowNum: 10,
		rowList: [10, 30, 50],
		rownumbers: true,
		rownumWidth: 25,
		autowidth: true,
		multiselect: true,
		pager: "#jqGridPagerShengben",
		jsonReader: {
			root: "page.list",
			page: "page.currPage",
			total: "page.totalPage",
			records: "page.totalCount"
		},
		prmNames: {
			page: "page",
			rows: "limit",
			order: "order"
		},
		gridComplete: function() {
			//隐藏grid底部滚动条
			$("#jqGridShengben").closest(".ui-jqgrid-bdiv").css({
				"overflow-x": "hidden"
			});
		}
	});
	$("#jqGridKaoyan").jqGrid({
		url: baseURL + 'gaokaobaobei/zhaosheng/listKaoyan',
		datatype: "json",
		colModel: [{
				label: '姓名',
				name: 'name',
				index: 'name',
				width: 80
			},
			{
				label: '考号',
				name: 'candidateNumber',
				index: 'candidate_number',
				width: 120
			},
			{
				label: '分数',
				name: 'score',
				index: 'score',
				width: 80
			},
			{
				label: '大学',
				name: 'highSchool',
				index: 'high_school',
				width: 110
			},
			{
				label: '联系电话',
				name: 'phone',
				index: 'phone',
				width: 110
			},
			{
				label: '报备时间',
				name: 'creationDate',
				index: 'creation_date',
				width: 150
			},
			{
				label: '备注',
				name: 'candidateNumber',
				index: 'candidate_number',
				width: 120,
				formatter: function(data, a, rows) {
					if(rows.type == '等待录取结果') {
						return `备注:`;
					} else if(rows.type == '审核未通过') {
						return `<font color="#228b22">备注:${rows.school}</font>&nbsp;&nbsp;<font color="red">原因:${rows.major}</font> `;
					} else {
						return `<font color="#228b22">备注:${rows.school}</font> `;
					}
					if(rows.type == '等待录取结果') {
						return `${data}<br>备注:<input id="xk${data}" />`;
					} else if(rows.type == '审核未通过') {
						return `${data}<br><font color="#228b22">备注:${rows.school}</font>&nbsp;&nbsp;<font color="red">原因:${rows.major}</font> `;
					} else {
						return `${data}<br><font color="#228b22">备注:${rows.school}</font> `;
						if(rows.type == '等待录取结果') {
							return `备注:<input id="xk${data}" />`;
						} else if(rows.type == '审核未通过') {
							return `<font color="#228b22">备注:${rows.school}</font>&nbsp;&nbsp;<font color="red">原因:${rows.major}</font> `;
						} else {
							return `<font color="#228b22">备注:${rows.school}</font> `;
						}
					}

				}
			},
			{
				label: '状态',
				name: 'cz',
				index: 'cz',
				width: 100,
				formatter: function(data, a, rows) {
					if(rows.type == '审核通过') {
						return `<font color="#228b22">审核通过</font>`
					}
				}
			},
		],
		viewrecords: true,
		height: 385,
		rowNum: 10,
		rowList: [10, 30, 50],
		rownumbers: true,
		rownumWidth: 25,
		autowidth: true,
		multiselect: true,
		pager: "#jqGridPagerKaoyan",
		jsonReader: {
			root: "page.list",
			page: "page.currPage",
			total: "page.totalPage",
			records: "page.totalCount"
		},
		prmNames: {
			page: "page",
			rows: "limit",
			order: "order"
		},
		gridComplete: function() {
			//隐藏grid底部滚动条
			$("#jqGridKaoyan").closest(".ui-jqgrid-bdiv").css({
				"overflow-x": "hidden"
			});
		}
	});
});

function selectXiakao(name) {
	vm.showList = 1;
	var pageXiakao = $("#jqGridXiakao").jqGrid('getGridParam', 'page');
	$("#jqGridXiakao").jqGrid('setGridParam', {
		postData: {
			"name": name,
		},
		page: pageXiakao
	}).trigger("reloadGrid");
	$("#jqGridXiakao").setGridWidth($(window).width());
}
function selectDanzhao(name) {
	vm.showList = 2;
	var pageDanzhao = $("#jqGridDanzhao").jqGrid('getGridParam', 'page');
	$("#jqGridDanzhao").jqGrid('setGridParam', {
		postData: {
			"name": name,
		},
		page: pageDanzhao
	}).trigger("reloadGrid");
	$("#jqGridXiakao").setGridWidth($(window).width());
}
function selectShengben(name) {
	vm.showList = 3;
	var pageShengben = $("#jqGridShengben").jqGrid('getGridParam', 'page');
	$("#jqGridShengben").jqGrid('setGridParam', {
		postData: {
			"name": name,
		},
		page: pageShengben
	}).trigger("reloadGrid");
	$("#jqGridXiakao").setGridWidth($(window).width());
}
function selectKaoyan(name) {
	vm.showList = 4;
	var pageKaoyan = $("#jqGridKaoyan").jqGrid('getGridParam', 'page');
	$("#jqGridKaoyan").jqGrid('setGridParam', {
		postData: {
			"name": name,
		},
		page: pageKaoyan
	}).trigger("reloadGrid");
	$("#jqGridXiakao").setGridWidth($(window).width());
}

var vm = new Vue({
	el: '#rrapp',
	data: {
		showList: 0,
		title: null,
		agency: {},
	},
	methods: {
		//      queryZN:function(){
		//          var pageZN = $("#jqGridZN").jqGrid('getGridParam', 'page');
		//          $("#jqGridZN").jqGrid('setGridParam', {
		//              postData: {"name":vm.username,
		//                          "Admissionstype":vm.Admissionstype
		//              },
		//              page: pageZN
		//          }).trigger("reloadGrid");
		//      },
		query: function() {
			vm.reload();
		},
		//      add: function () {
		//          vm.showList = 1;
		//          vm.title = "新增";
		//          vm.agency = {};
		//      },
		//      update: function (event) {
		//          var id = getSelectedRow();
		//          if (id == null) {
		//              return;
		//          }
		//          vm.showList = 1;
		//          vm.title = "修改";
		//
		//          vm.getInfo(id)
		//      },
		//      saveOrUpdate: function (event) {
		//          var url = vm.agency.id == null ? "gaokaobaobei/agency/save" : "gaokaobaobei/agency/update";
		//          $.ajax({
		//              type: "POST",
		//              url: baseURL + url,
		//              contentType: "application/json",
		//              data: JSON.stringify(vm.agency),
		//              success: function (r) {
		//                  if (r.code === 0) {
		//                      alert('操作成功', function (index) {
		//                          vm.reload();
		//                      });
		//                  } else {
		//                      alert(r.msg);
		//                  }
		//              }
		//          });
		//      },
		//      del: function (event) {
		//          var ids = getSelectedRows();
		//          if (ids == null) {
		//              return;
		//          }
		//          confirm('确定要删除选中的记录？', function () {
		//              $.ajax({
		//                  type: "POST",
		//                  url: baseURL + "gaokaobaobei/agency/delete",
		//                  contentType: "application/json",
		//                  data: JSON.stringify(ids),
		//                  success: function (r) {
		//                      if (r.code == 0) {
		//                          alert('操作成功', function (index) {
		//                              $("#jqGrid").trigger("reloadGrid");
		//                          });
		//                      } else {
		//                          alert(r.msg);
		//                      }
		//                  }
		//              });
		//          });
		//      },
		getInfo: function(id) {
			$.get(baseURL + "gaokaobaobei/agency/info/" + id, function(r) {
				vm.agency = r.agency;
			});
		},
		reload: function(event) {
			vm.showList = 0;
			var page = $("#jqGrid").jqGrid('getGridParam', 'page');
			$("#jqGrid").jqGrid('setGridParam', {
				page: page
			}).trigger("reloadGrid");
		}
	}
})